/***************************************************************************
 *   Copyright (C) 2010 by Fabio Galbusera   *
 *   fabio.galbusera@uni-ulm.de   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef CMATRIX_H
#define CMATRIX_H

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "parameters.h"

/**
	@author Fabio Galbusera <fabio.galbusera@uni-ulm.de>
*/
class CMatrix{
public:
    CMatrix(int r, int c);
    ~CMatrix();
    void setIdentity();
    void set(int r, int c, double v);
    double get(int r, int c);
    void setP1(int r, int c, double v);
    double getP1(int r, int c);
    void print();
    void swapRows(int r1, int r2);
    CMatrix* solveGauss(CMatrix *rhs);
    CMatrix* solveGaussSeidel(CMatrix *rhs);
    void setZero();
    void add(int r, int c, double v);
	CMatrix* copy();
	int countNoZeros();
	int getNRows();
	int getNCols();
private:
    int nr;
    int nc;
    double *values;

};

#endif
